package StudyCode.summary.mycollection;

import java.lang.reflect.Array;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GenericMethodToCloneArray {
	public static <T> T[] clone_array(T[] array, Class<T> cls) {
		T[] copy = (T[]) Array.newInstance(cls, array.length);

		for (int i = 0; i < array.length; i++) {
			copy[i] = array[i];
		}
		return copy;
	}
}
